#include "stdafx.h"
#include "PKCScontent.h"

namespace AppliedCryptography
{
	PKCSContent::PKCSContent(ClassBits classBits, ConstructedBit constucted, TypeNumberBits number)
		: ASN1Encodable(classBits, constucted, number),
		_contentOID(new ASN1ObjectIdentifier())
	{
	};
	
	PKCSContent::PKCSContent(ASN1ObjectIdentifier* contentOID)
		: ASN1Encodable(ContextSpec, Constructed, Explicit00),
		_contentOID(contentOID)
	{
	};

	PKCSContent::PKCSContent(std::string contentOIDValue, ASN1ObjectIdentifier* contentOID)
		: ASN1Encodable(ContextSpec, Constructed, Explicit00),
		_contentOID(contentOID)
	{
		_contentOID->set(contentOIDValue);
	};

	PKCSContent::~PKCSContent()
	{
		//delete _contentOID;
	};

	ASN1ObjectIdentifier& PKCSContent::getPKCSContentType() const
	{
		return *_contentOID;
	};

	PKCSContent& PKCSContent::setPKCSContentType(ASN1ObjectIdentifier& oid)
	{
		_contentOID = &oid;
		return *this;
	};

	ASN1Encodable& PKCSContent::getPKCSContent() const
	{
		return *_content;
	};

	PKCSContent& PKCSContent::setPKCSContent(ASN1Encodable* content)
	{
		_content = content;
		return *this;
	};

	std::vector<byte> PKCSContent::getContentBits() const
	{
		return this->getPKCSContent().encode();
	};
}; // namespace AppliedCryptography
